//
//  webViewController.swift
//  二次源
//
//  Created by 李建文 on 2017/2/28.
//  Copyright © 2017年 二次源. All rights reserved.
//

import UIKit

class webViewController: UIViewController ,UIWebViewDelegate, UITextFieldDelegate{
    
    @IBOutlet weak var webView: UIWebView!

    @IBAction func didCancel(_ sender: AnyObject) {
        backToPrevious()
    }
    var temp:String?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.temp = self.navigationController?.title
        print(temp)
        
        self.webView.delegate = self
        if(temp=="0"){
            loadUrl(url: "http://192.168.137.1:8080/ecy1.0/index.html")
        }else if(temp=="1"){
            loadUrl(url: "http://192.168.137.1:8080/ecy1.0/index1.html")
        }else if(temp=="2"){
            loadUrl(url: "http://192.168.137.1:8080/ecy1.0/index2.html")
        }
        
        // Do any additional setup after loading the view.

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    /*
     在 UIWebView 加载指定 URL
     */
    func loadUrl(url:String)
    {
        // 发送网络请求
        let url:NSURL = NSURL(string:url)!
        let request:NSURLRequest = NSURLRequest(url:url as URL)
        webView.loadRequest(request as URLRequest)
        
        // 设置UIWebView接收的数据是否可以通过手势来调整页面内容大小
        webView.scalesPageToFit = true
        
        // 设置UIWebView的代理对象
        webView.delegate = self
    }
    
    //返回按钮点击响应
    func backToPrevious(){
        self.dismiss(animated: true, completion: nil)
    }
    


}
